Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unmarshalling and implement a RetryFunc #104

Merged
merged 3 commits into from
Feb 24, 2024

Conversation

manicminer
Copy link
Collaborator

@manicminer manicminer force-pushed the f/unmarshalling-and-retries branch 2 times, most recently from c1e9de0 to c9b0ac7 Compare February 20, 2024 12:39
Comment on lines +52 to +66
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return false, fmt.Errorf("could not parse response body")
}
resp.Body.Close()
respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf"))
res := ErrorResponse{}
if err = xml.Unmarshal(respBody, &res); err != nil {
return false, err
}
resp.Body = io.NopCloser(bytes.NewBuffer(respBody))
if res.Code != nil {
return strings.Contains(*res.Code, "ContainerBeingDeleted"), nil
}
Copy link
Collaborator Author

@manicminer manicminer Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: it might be worth changing RetryFunc so that it's passed a client.Response rather than an http.Response, which would make common parsing a little cleaner. I can do that as part of this change if anyone thinks that's warranted? Or we could do that later when more RetryFuncs are added.

Copy link
Owner

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor points but otherwise LGTM 👍

go.mod Outdated
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240125.1111756
github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1115017
github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wants updating to a stable version

storage/2023-11-03/file/shares/create.go Outdated Show resolved Hide resolved
storage/2023-11-03/blob/containers/create.go Outdated Show resolved Hide resolved
@manicminer manicminer force-pushed the f/unmarshalling-and-retries branch from e57d964 to dfec5fd Compare February 24, 2024 01:57
@manicminer manicminer merged commit a046cd9 into main Feb 24, 2024
1 check passed
@manicminer manicminer deleted the f/unmarshalling-and-retries branch February 24, 2024 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants